package com.chinafree.business.controller;


import com.chinafree.business.model.param.DeliveryParam;
import com.chinafree.business.model.queryCondition.DeliveryQueryCondition;
import com.chinafree.business.model.result.DeliveryResult;
import com.chinafree.business.model.result.UserBaseMessageResult;
import com.chinafree.business.service.DeliveryService;
import com.chinafree.common.model.request.RequestParameter;
import com.chinafree.common.model.response.BaseResponse;
import com.chinafree.common.model.response.ListPagingResponse;
import com.fasterxml.jackson.databind.JsonSerializable.Base;

import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("delivery")
public class DeliveryController extends BaseController {


    @Autowired
    private DeliveryService deliveryService;

    @ApiOperation(value = "批量查询")
    @PostMapping("/queryPage")
    public ListPagingResponse<DeliveryResult> queryUserPage(@RequestBody RequestParameter<DeliveryQueryCondition> userQueryCondition) {
        return deliveryService.queryUserPage(userQueryCondition.getBody());
    }


    @ApiOperation(value = "批量查询")
    @PostMapping("/queryPageByJob")
    public ListPagingResponse<UserBaseMessageResult> queryUserPageByJob(@RequestBody RequestParameter<DeliveryQueryCondition> userQueryCondition ,@RequestParam("jobId") Long jobId) {
        return deliveryService.queryUserPageByJob(userQueryCondition.getBody(),jobId);
    }

    @ApiOperation(value = "批量查询")
    @PostMapping("/queryUserPageByCompany")
    public ListPagingResponse<UserBaseMessageResult> queryUserPageByCompany(@RequestBody RequestParameter<DeliveryQueryCondition> userQueryCondition ) {
        return deliveryService.queryUserPageByCompany(userQueryCondition.getBody(),getCompanyId());
    }


    @ApiOperation(value = "投递")
    @PostMapping("/insert")
    public BaseResponse insert(@RequestBody RequestParameter<DeliveryParam> deliveryParam) {
        return deliveryService.insert(deliveryParam.getBody());
    }

    @ApiOperation(value = "更新状态")
    @PostMapping("/update")
    public BaseResponse update(@RequestBody RequestParameter<DeliveryParam> deliveryParam) {
        return deliveryService.update(deliveryParam.getBody(),getUserId());
    }

    @ApiOperation(value = "更新状态")
    @PostMapping("/updateByUserId")
    public BaseResponse updateByUserId(@RequestBody RequestParameter<DeliveryParam> deliveryParam,@RequestParam("userId") Long userId) {
        return deliveryService.update(deliveryParam.getBody(),userId);
    }

    @ApiOperation(value = "更新状态")
    @PostMapping("/updateByCompanyId")
    public BaseResponse updateByCompanyId(@RequestBody RequestParameter<DeliveryParam> deliveryParam,@RequestParam("userId") Long userId) {
        return deliveryService.updateByCompanyId(deliveryParam.getBody(),userId);
    }

}

